//安装：npm i vee-validate@2 --save
//vee-validate插件：表单验证
import Vue from 'vue'
import VeeValidate from 'vee-validate'
//引入中文包
import zh_CN from 'vee-validate/dist/locale/zh_CN'
const config = {
    errorBagName: 'errorBags', // change if property conflicts.
    fieldsBagName: 'fieldBags',
};
Vue.use(VeeValidate, config);

//表单验证：
VeeValidate.Validator.localize('zh_CN', { //引入中文包
  messages:{
    ...zh_CN.messages,
    is: (field) => `${field}必须与密码相同`,//修改内置规则的message is: (field) => `${field}必须与密码相同`
  },
  //修改内置规则的name，对应的值变为中文
  attributes: {
    username: '邮箱',
    code: '验证码',
    password:'密码',
    repassword:'确认密码',
    agree:'协议'
  }})

//自定义校验规则
VeeValidate.Validator.extend('tongyi',{
  validate:value=>{
    return value
  },
  getMessage:field => field + '必须同意'
})